package logic.status;

import networking.messages.syncMessages.ValueType;
import logic.common.player.Player;
import map.spawnStation.SpawnStation;
import map.spawnStation.stationListeners.SpawnStationPointsListener;
import map.spawnStation.stationListeners.StationPointsChangedEvent;

public class SpawnValueManager extends StatusValueManager<SpawnStationPointsListener> {
	
	private SpawnStation station;
	
	public SpawnValueManager(SpawnStation station) {
		super(SpawnStationPointsListener.class);
		this.station = station;
	}
	
	@Override
	public StatusValueContainer<SpawnStationPointsListener> getNewContainer(float diff) {
		return new StatusValueContainer<SpawnStationPointsListener>(diff, listenerClass) {
			@Override
			protected String getListenerMethod() { return SpawnStationPointsListener.POINTSCHANGED; }
			
			@Override
			protected AbsChangedEvent getEvent(ValueType type, Object newValue) {
				Player lastPlayer = station.getLastCapturingPlayer();
				return new StationPointsChangedEvent(station, ((Float)newValue).floatValue(), lastPlayer);
			}
		};
	}
}